namespace Er
{
    using System;
    using System.Windows;

    using Microsoft.Practices.Composite.Modularity;
    using Microsoft.Practices.Composite.UnityExtensions;
    using Microsoft.Practices.Unity;

    internal class Bootstrapper : UnityBootstrapper
    {
        protected override IModuleCatalog GetModuleCatalog()
        {
            //            var moduleCatalog = new ModuleCatalog();
            //            moduleCatalog.AddModule(typeof(ExecuteModule));
            //            return moduleCatalog;
            //var moduleCatalog = new ConfigurationModuleCatalog();
            //moduleCatalog.AddModule(typeof(ExecuteModule));
             

            var moduleCatalog =
                ModuleCatalog.CreateFromXaml(new Uri(@"/Er.Shell;component/ModulesCatalog.xaml", UriKind.Relative));

            return moduleCatalog;
        }

        protected override DependencyObject CreateShell()
        {
            Container.RegisterType<IShellView, ShellView>(new ContainerControlledLifetimeManager());
            Container.RegisterType<IShellViewModel, ShellViewModel>(new ContainerControlledLifetimeManager());

            var view = Container.Resolve<IShellView>();
            view.ShowView();
            return view as DependencyObject;
        }
    }

    public interface IShellView
    {
        IShellViewModel ViewModel { get; }

        void ShowView();
    }

    public interface IShellViewModel
    {
    }

    public class ShellViewModel : IShellViewModel
    {
    }

    //    [Module(ModuleName = "ExecuteModule")]
    public class ExecuteModule : IModule
    {
        private readonly IUnityContainer _container;

        public ExecuteModule(IUnityContainer container)
        {
            _container = container;
        }

        public void Initialize()
        {
        }
    }
}